package Work5;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;


class NumberPrinter implements Runnable {
	
    private static int number = 1;
    public void run() {
        while (number <= 52) {
            synchronized (lock) {
                try {
                    if (Thread.currentThread().getName().equals("Thread-0")) {
                        System.out.print(number++);
                    } else {
                        lock.wait();
                    }
                    lock.notify();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
